package edu.pku.sei.modeler.neditor.ui;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import edu.pku.sei.modeler.model.notation.shape.ConnectionTemplate;
import edu.pku.sei.modeler.model.notation.shape.Ellipse;
import edu.pku.sei.modeler.model.notation.shape.Polygon;
import edu.pku.sei.modeler.model.notation.shape.Polyline;
import edu.pku.sei.modeler.model.notation.shape.TextObject;
import edu.pku.sei.modeler.neditor.model.Diagram;
import edu.pku.sei.modeler.neditor.part.ConnectionEditPart;
import edu.pku.sei.modeler.neditor.part.DiagramEditPart;
import edu.pku.sei.modeler.neditor.part.EllipseEditPart;
import edu.pku.sei.modeler.neditor.part.PolygonEditPart;
import edu.pku.sei.modeler.neditor.part.PolylineEditPart;
import edu.pku.sei.modeler.neditor.part.TextObjectEditPart;

public class NotationEditPartFactory implements EditPartFactory {

	public EditPart createEditPart(EditPart context, Object model) {
		Class type = model.getClass();
		EditPart part = null;
		if(type==Diagram.class){
			part = new DiagramEditPart();
		} else if(type==Polygon.class){
			part = new PolygonEditPart();
		} else if(type==Polyline.class) {
			part = new PolylineEditPart();
		} else if(type==TextObject.class) {
			part = new TextObjectEditPart();
		} else if(type==ConnectionTemplate.class){
			part = new ConnectionEditPart();
		} else if(type == Ellipse.class) {
			part = new EllipseEditPart();
		}
		part.setModel(model);
		return part;
	}
}
